
var  highlightcolor='#eafcd5';

var  clickcolor='#fafcd5';

function  changeto(){
	source=event.srcElement;
	if  (source.tagName=="TR"||source.tagName=="TABLE")return;
	while(source.tagName!="TD")
		source=source.parentElement;
	source=source.parentElement;
	cs  =  source.children;
	//alert(cs.length);
	if  (cs[1].style.backgroundColor!=highlightcolor&&source.id!="nc"&&cs[1].style.backgroundColor!=clickcolor){
		for(i=0;i<cs.length;i++){
			cs[i].style.backgroundColor=highlightcolor;
		}
	}
}

function  changeback(){
	if  (event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="nc")return;
	if  (event.toElement!=source&&cs[1].style.backgroundColor!=clickcolor){
	
		for(i=0;i<cs.length;i++){
			cs[i].style.backgroundColor="";
		}
	}
}

function  clickto(){
	source=event.srcElement;
	changeColor(source);
}

function  changeColor(source){
	var flag = source.checked;
	if  (source.tagName=="TR"||source.tagName=="TABLE")return;
	while(source.tagName!="TD")
		source=source.parentElement;
	source=source.parentElement;
	cs  =  source.children;
	//alert(cs.length);
	//if  (cs[1].style.backgroundColor!=clickcolor&&source.id!="nc"){
	if  (flag){
		for(i=0;i<cs.length;i++){
			cs[i].style.backgroundColor=clickcolor;
		}
	}else{
		for(i=0;i<cs.length;i++){
			cs[i].style.backgroundColor="";
		}
	}
}


//全选按钮实现(onclick事件调用)
var flag = 1;
function selectAll(name) {
	var selects = document.getElementsByName(name);
	if (flag == 1) {
		for (var i = 0; i < selects.length; i++) {
			selects[i].checked = true;
			changeColor( selects[i] );
		}
		flag = 0;
	} else {
		if (flag == 0) {
			for (var i = 0; i < selects.length; i++) {
				selects[i].checked = false;
				
				changeColor( selects[i] );
			}
			flag = 1;
		}
	}
}

function deleteSelectedOptions(name){
	var ids = "";
	var selects = document.getElementsByName(name);
	for (var i = 0,j = 0; i < selects.length; i++) {
		if( selects[i].checked ){
			
			if( j == 0 )
				ids = selects[i].value;
			else
				ids += "," + selects[i].value;
			
			j++;	
		}
	}
	
	if( ids == "" ){
		alert( "没有可删除项！" );
	}else{
		alert( ids );
	}
	
function getSelectedOptionsIds(name){
	
	var ids = "";
	var selects = document.getElementsByName(name);
	for (var i = 0; i < selects.length; i++) {
		if( selects[i].checked ){
			
			if( i == 0 )
				ids = selects[i].value;
			else
				ids += "," + selects[i].value;
		}
	}
	alert(ids);
	return ids ;
}	

}
